package yartiss.engine.simulation.energy.profiles;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import yartiss.engine.simulation.IEnergyProfile;

public class EnergyProfileFactory {
	
	private static Map<String, IEnergyProfile> profiles = new HashMap<String, IEnergyProfile>();
	
	static {
		List<IEnergyProfile> profilesList = new ArrayList<IEnergyProfile>();
		profilesList.add(new DefaultEnergyProfile(0, 0, 0, 0));
		for (IEnergyProfile p : profilesList) {
			profiles.put(p.getName(), p);
		}
		profiles.put("defaultEnergyProfile", new DefaultEnergyProfile(0, 0, 0, 0)) ;
	}
	
	public static void registerProfile(IEnergyProfile p){
		profiles.put(p.getName(), p);
	}
	
	public static IEnergyProfile getInstance(String energyProfileName, int ... params){
		if(params.length <3)throw new IllegalArgumentException("few arguments");
		if(profiles.containsKey(energyProfileName))
			return profiles.get(energyProfileName).newInstance(params);
		throw new IllegalArgumentException("EnergyProfileFactory : "+energyProfileName+" not found" );
	}
	
	public  static String [] getAvailableProfiles(){
		String [] list = new String [profiles.size()];
		int i=0;
		for (String p : profiles.keySet()) {
			list[i++]=p;
		}
		return list;
	}
}
